<h5>Interfacing the Wiring hardware and Perl</h5>
<p>This tutorial introduces the basic interfacing between the Wiring hardware and Perl <a href="http://www.perl.org/">http://www.perl.org/</a>. The brief for the tutorial will be to read simple values from the Wiring board. It assumes the Wiring software and Perl are installed and the proper Wiring setup has been previously completed. For more Information on Wiring install check out the tutorials about Wiring installation and software setup.</p>
<p>For this tutorial, the used IDE is Eclipse <a href="http://www.eclipse.org/">http://www.eclipse.org/</a>with EPIC <a href="http://www.epic-ide.org/">http://www.epic-ide.org/</a> as the Perl editor.</p>
<h5>Step 1</h5>
<p>Copy and paste the following code on the Wiring editor: Verify your program is free of compiling errors by pressing the Compile/Verify button in the menu bar. Press the Upload button in the menu bar. In case of syntax errors the Wiring environment will print the error messages otherwise it will print the Upload was completed successfully, the uploading process triggers activity in the Rx/Tx LEDs on the Wiring hardware. The new program will start automatically after uploading. Use the Serial Monitor button to watch the data coming from the Wiring board, then close the Serial Monitor again.</p>
<pre>
/** 
 * Fotoresitencia / Perl
 * 
 * Reads values from a photoresistor connected to the <br> * analog input pin 0. The value read from the sensor is proportion<br> * to the amount of light that hits the sensor surface.<br> * The value read is printed through the serial to be monitored<br> * in the console or received on Perl<br> */

int val; 

void setup()
{
  Serial.begin(9600);      // sets the serial port to 9600
}

void loop() 
{
  val = analogRead(0);     // read analog input pin 0
  Serial.println(val/4, DEC);  // prints the value read from the
                               // sensor in analog pin 0 divided by 4 (range 0-255)
  delay(200);                  // wait 200ms for next reading
}</pre>
<h5>Step 2</h5>
<p>Download and install the perl´s package named Device::SerialPort using Terminal or Command Prompt for Windows. Use the next lines of code to make the installation. </p>
<pre>
perl -MCPAN -e shell
install Device::SerialPort
exit</pre>
<h5>Step 3</h5>
<p>Create a new Perl project in Eclipse. Copy and paste the next code in the editor.</p>
<pre>
#!/usr/bin/perl
use Device::SerialPort;

# Set up the serial port
# Change the port name
my $port = Device::SerialPort->new("/dev/tty.usbserial-A100DNHF");
# Change the baudrate if you need it
$port->baudrate(9600);
$port->databits(8);
$port->parity(10);
$port->stopbits(1);

while (1) {
    # Poll to see if any data is coming in
    my $char = $port->lookfor();

    # If we get data, then print it
    if ($char) {
        print "Recieved character: $char \n";
    }
}</pre>
<h5>Step 4</h5>
<p>Compile the code and the received data must be printed in the Eclipse console.</p>
<p><img src="imgs/perl-01.png" width="489" height="316" /></p>
<p>&nbsp;</p>
<p>Next &gt;&gt; <a href="blender2.html"> Sending data to the Wiring board from Perl.</a></p>
